// pages/order/order.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    imageUrl:"http://cdn.pixabay.com/photo/2014/09/14/14/21/currywurst-445022_1280.jpg",
    foodimages: [
      "http://cdn.pixabay.com/photo/2014/09/14/14/21/currywurst-445022_1280.jpg",
      "http://cdn.pixabay.com/photo/2016/03/27/21/59/bread-1284438_1280.jpg"
    ],
    navList: [
      { value:1, title: '未完成', index: 0 },
      { value:2, title: '全部', index: 1 },
      { value:3, title: '已完成', index: 2 },
    ],
    num: 3,
    orderid:wx.getStorageSync('orderid'),
    takingId:"011",
    time:"2023-07-04 16:00:00",
    totalPrice:100,
    foodList:[
      {"name":"臭豆腐",
       "num":"1",
       "price":"100",
       "details":"闻着臭吃着香"
      },
      {"name":"老干妈",
      "num":"1",
      "price":"100",
      "details":"经典美味"
     },
     {"name":"黄瓜丝儿",
       "num":"1",
       "price":"100",
       "details":"清脆爽口"
      },
      {"name":"臭豆腐",
       "num":"1",
       "price":"100",
       "details":"闻着臭吃着香"
      },
      {"name":"臭豆腐",
       "num":"1",
       "price":"100",
       "details":"闻着臭吃着香"
      }
    ]
  },
  // 跳转评价
  onTabjump:function(event){
    wx.navigateTo({
      url: '/pages/evaluation/evaluation',
      success:function(){
        console.log('jumpsuccess')
      },
      fail:function(){
        console.log('jumpfail')
      },

    })
  },

  onLoad() {
    let orderid=this.data.orderid
    console.log(orderid)
    this.getOrderdetails();
  },
  getOrderdetails(){
    var that = this;
    let id=wx.getStorageSync('orderid')
    console.log(id)
    //请求
    wx.request({
      url: 'http://localhost:8080/Orders/getDetailOrder/'+id,
      method: 'GET',
      success: function(res) {
        var foodList = res.data.commodities;
        that.setData({
          takingId:res.data.orders.takingId,
          foodList: foodList,
          time:res.data.orders.orderTime,
          totalPrice:res.data.orders.totalPrice,
        });
        wx.setStorageSync('totalPrice', totalPrice)
      },
      fail: function(error) {
        console.log(error);
      }
    });
  },
})